/**
 * @desc 组织维护相关的dic
 *
 * @author zhanghao at 2020-06-18
 *
 * */
import { FormDicType } from 'orgc-manage';

// 初始化进来默认的虚拟node
const SELECT_NODE = {
    isRoot: true, name: 'org.orgStrc', nodeName:  'org.orgStrc', id: '0', parentId: '0', code: 'root', nodeType: 'COMPANY', isLeaf: false, typeName: '', children: null,
}
// 默认的节点类型
const INIT_NODE_FORM: FormDicType[] = [
    { txt:'org.nodeType', key: 'modalSelectType', type: 'redioGrp', disabled: false },
];
// 上级节
const PARENT_NODE: FormDicType[] = [
    { txt: 'org.parentNode', key: 'parentNodeName', type: 'input', disabled: true },
];
// 列表查询
const NODE_FORM: FormDicType[] = [
    { txt:'org.nodeCode', key: 'code', type: 'input' },
    { txt: 'org.nodeName', key: 'name', type: 'input' },
];
// 公司Form
const COMPANY_FORM: FormDicType[] = [
    { txt: 'org.company.code', key: 'code', type: 'input', isRequired: true },
    { txt: 'org.company.name', key: 'name', type: 'input', isRequired: true },
    { txt: 'org.company.region', key: 'region', type: 'input', isRequired: true },
    // { txt: '是否可邮寄', key: 'isMail', type: 'select', isRequired: true, attrCode: 'YES_OR_NO', },
    { txt: 'org.company.uniCrCode', key: 'uniCrCode', type: 'input' },
    { txt: 'org.company.legal', key: 'legal', type: 'input' },
    { txt: 'org.company.phone', key: 'phone', type: 'input' },
    { txt: 'org.company.addr', key: 'addr', type: 'input' },
];
// 部门
const DEPARTMENT_FORM: FormDicType[] = [
    { txt: 'org.department.code', key: 'code', type: 'input', isRequired: true },
    { txt: 'org.department.name', key: 'name', type: 'input', isRequired: true },
    { txt: 'org.department.cntct', key: 'cntct', type: 'input' },
    { txt: 'org.department.phone', key: 'phone', type: 'input' },
    { txt: 'org.department.email', key: 'email', type: 'input' },
];
// 岗位
const JOB_FORM: FormDicType[] = [
    { txt: 'org.job.code', key: 'code', type: 'input', isRequired: true },
    { txt: 'org.job.name', key: 'name', type: 'input', isRequired: true },
];
// 员工
const EMPLOYEE_FORM: FormDicType[] = [
    { txt: 'org.employee.code', key: 'code', type: 'selectTable', isRequired: true },
    { txt: 'org.employee.name', key: 'name', type: 'input', isRequired: true, disabled: true },
    {
        txt: 'org.employee.flagAdmin',
        key: 'flagAdmin',
        type: 'select',
        isRequired: true,
        attrCode: 'YES_OR_NO',
    },
    {
        txt: 'org.employee.flagOperate',
        key: 'flagOperate',
        type: 'select',
        isRequired: true,
        attrCode: 'YES_OR_NO',
    },
];

const NODE_TYPE_OBJ = {
    COMPANY: {
        name: 'org.parentCompany',
        form: COMPANY_FORM,
        defaultNextType: 'CHILD_COMPANY',
        addApi: 'companyCreate',
        updateApi: 'companyUpdate',
        detailApi: 'companyDetail',
        delApi: 'companyDelete',
        idName: 'code',
    },
    CHILD_COMPANY: {
        name: 'org.company',
        form: COMPANY_FORM,
        defaultNextType: 'DEPARTMENT',
        addApi: 'companyCreate',
        updateApi: 'companyUpdate',
        detailApi: 'companyDetail',
        delApi: 'companyDelete',
        idName: 'code',
    },
    DEPARTMENT: {
        name: 'org.department',
        form: DEPARTMENT_FORM,
        defaultNextType: 'DEPARTMENT',
        addApi: 'departmentCreate',
        updateApi: 'departmentUpdate',
        detailApi: 'departmentDetail',
        delApi: 'departmentDelete',
        idName: 'code',
    },
    JOB: {
        name: 'org.job',
        form: JOB_FORM,
        defaultNextType: 'EMPLOYEE',
        addApi: 'treeCreateNode',
        updateApi: 'treeUpdateNode',
        detailApi: null,
        delApi: 'treeDeleteNode',
        idName: 'code',
    },
    EMPLOYEE: {
        name: 'org.employee',
        form: EMPLOYEE_FORM,
        addApi: 'addOrgRefUser',
        updateApi: null,
        detailApi: 'userDetailByOrg',
        delApi: 'employeeDelRef',
        idName: 'userCode',
    },
}
export {
    NODE_FORM, INIT_NODE_FORM,
    SELECT_NODE, NODE_TYPE_OBJ,
    COMPANY_FORM, JOB_FORM, EMPLOYEE_FORM, PARENT_NODE,
};
